package net.dgg.zz.common.service;

import com.alibaba.fastjson.JSONObject;
import net.dgg.iboss.base.util.http.HttpUtility;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.Map;

@Service
public class NodeTimeOutPunishService {
    @Value("${scCmsUrl}")
    private  String sccmsUrl;
    private String nodeTimeOutPunishApi="/api/sc_cms/out/service/saveTimeoutPunish.do";
    private String matchingPunishApi="/api/sc_cms/out/service/savePunish.do";

    /**
     * 节点扣罚
     * @param map
     * @return
     */
    public Integer nodeTimeOutPunish(Map map){
        try {
            String resultStr = HttpUtility.postJson(this.sccmsUrl+this.nodeTimeOutPunishApi,map);
            JSONObject result = JSONObject.parseObject(resultStr);
            //修改状态为已扣罚
           return result.getInteger("code");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return 1;
    }

    /**
     * 证书匹配扣罚
     * @param map
     * @return
     */
    public Integer matchingtPunish(Map map){
        try {
            String resultStr = HttpUtility.postJson(this.sccmsUrl+this.matchingPunishApi,map);
            JSONObject result = JSONObject.parseObject(resultStr);
            //修改状态为已扣罚
            return result.getInteger("code");
        } catch (IOException e) {
            e.printStackTrace();
        }
        return 1;
    }
}
